//
//  MKBottomView.swift
//  Weibo
//
//  Created by mac on 15/12/18.
//  Copyright © 2015年 MK. All rights reserved.
//

import UIKit
import SnapKit

class MKBottomView: UIView {
    
    //入口
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setUpSubViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //设置子视图
    func setUpSubViews() {
        
        addSubview(tweeterBtn)
        addSubview(commentBtn)
        addSubview(loveBtn)
        
        tweeterBtn.snp_makeConstraints { (make) -> Void in
           make.top.left.bottom.equalTo(self)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(tweeterBtn.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(tweeterBtn.snp_width)
        }
        
        loveBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.top.bottom.right.equalTo(self)
            make.width.equalTo(commentBtn.snp_width)
        }
        
        let leftLineView = getSeparator()
        let rightLineView = getSeparator()
        addSubview(leftLineView)
        addSubview(rightLineView)
        let speatatorWidth: CGFloat = 0.5
        let scale: CGFloat = 0.4
        
        leftLineView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(tweeterBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(speatatorWidth)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        
        rightLineView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(speatatorWidth)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
        }
        
        
        
    }
    
    //分割线
    private func getSeparator() -> UIView {
        let view = UIView()
        view.backgroundColor = UIColor(white: 0.8, alpha: 1)
        return view
    }
    
    //懒加载子视图
    lazy var tweeterBtn: UIButton = UIButton(imageName: "timeline_icon_retweet", titleColor: UIColor.grayColor(), titleName: "转发", titleFont: 10, isnothighLight: true)
    lazy var commentBtn: UIButton = UIButton(imageName: "timeline_icon_comment", titleColor: UIColor.grayColor(), titleName: "评论", titleFont: 10, isnothighLight: true)
    lazy var loveBtn: UIButton = UIButton(imageName: "timeline_icon_unlike", titleColor: UIColor.grayColor(), titleName: "赞", titleFont: 10, isnothighLight: true)
    
}
